<template>
  <van-form @submit="onSubmit" style="width: 80%">
    <van-field
      v-model="formData.email"
      :label-width="50"
      label="邮箱:"
      placeholder="请输入您的邮箱"
    />
    <van-field
      v-model="formData.password"
      :label-width="50"
      label="密码:"
      placeholder="请输入您的密码"
    />
    <van-cell>
      <van-button type="primary" text="登录" round block native-type="submit" />
    </van-cell>
  </van-form>
</template>

<script>
import { reactive } from "vue";
import { useStore } from "vuex";
export default {
  setup() {
    const store = useStore();
    let formData = reactive({
      email: "",
      password: "",
    });
    const onSubmit = () => {
      store.dispatch("Login", formData).then((res) => {
        console.log(res);
      });
    };
    return {
      formData,
      onSubmit,
    };
  },
};
</script>